<?php

function loadPlayerDeltas($order) {
  $deltas = array();
  $rs = executeQuery("select pd.completions + (3 * pd.touchdowns) + (2* pd.interceptions) + (2 * pd.casualties) as spps, pd.completions, pd.touchdowns, pd.interceptions, pd.casualties, pd.mvps, pd.exps, pd.completions + (3 * pd.touchdowns) + (2* pd.interceptions) + (2 * pd.casualties) + (5 * pd.mvps) + pd.exps as mvp_spps, p.name, p.position, p.ma, p.st, p.ag, p.av, p.skills, p.roster_num, p.fk_team_id, p.player_id from player_deltas pd, players p where p.player_id = pd.fk_player_id order by $order desc, 8 desc, 1 desc, 16, 15 LIMIT 0, 25");
  while($row = mysql_fetch_row($rs)) {
    array_push($deltas, new PlayerDelta($row));
  }
  return $deltas;
}

class PlayerDelta {
  var $completions = 0;
  var $tds = 0;
  var $interceptions = 0;
  var $casualties = 0;
  var $mvps = 0;
  var $exps = 0;
  var $spps = 0;
  var $otherSpps = 0;
  var $name;
  var $position;
  var $ma;
  var $st;
  var $ag;
  var $av;
  var $rosterNum;
  var $teamId;
  var $playerId;

  function PlayerDelta($row) {
    $i = 0;
    $this->otherSpps = $row[$i++];
    $this->completions = $row[$i++];
    $this->tds = $row[$i++];
    $this->interceptions = $row[$i++];
    $this->casualties = $row[$i++];
    $this->mvps = $row[$i++];
    $this->exps = $row[$i++];
    $this->spps = $row[$i++];
    $this->name = $row[$i++];
    $this->position = $row[$i++];
    $this->ma = $row[$i++];
    $this->st = $row[$i++];
    $this->ag = $row[$i++];
    $this->av = $row[$i++];
    $this->skills = $row[$i++];
    $this->rosterNum = $row[$i++];
    $this->teamId = $row[$i++];
    $this->playerId = $row[$i++];
  }
}
?>